package com.car.controller;


import com.car.entity.Subscribe;
import com.car.service.ISubscriService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
public class SubscribeConller {

    @Autowired
    @Qualifier("subscriService")
    private ISubscriService iSubscriService;

    //本店预约查询所有
    @RequestMapping( value = "/findsubAll")
    public String findSubAll(Model model){
        List<Subscribe> sub = iSubscriService.findAll();
        model.addAttribute("sub",sub);
        return "/Appointment.jsp";
    }

    //本店预约单个查询
    @RequestMapping( value = "/dgc")
    public String SubById(Model model,int id){
        Subscribe sub = iSubscriService.subById(id);
        model.addAttribute("sub1",sub);
        return "appoint_Detail.jsp";
    }

    //本店预约修改
    @RequestMapping( value = "/update",method = RequestMethod.POST)
    public String Subupdate(Subscribe subscribe){
        System.out.println(subscribe+"本店预约修改");
        iSubscriService.subupdate(subscribe);
        return "redirect:/findsubAll";
    }

    //本店预约模糊查询
    @RequestMapping( value = "/mhcx")
    public String mhcx(Subscribe subscribe,Model model){
        System.out.println(subscribe);
        List<Subscribe> sublist = iSubscriService.fuzzy(subscribe);
        System.out.println(sublist);
        model.addAttribute("sub",sublist);
        return "/Appointment.jsp";
    }
    //本店预约今日预约
    @RequestMapping(value = "jryy")
    public String makejr(Model model){
        List<Subscribe> li = iSubscriService.make();
        System.out.println(li);
        model.addAttribute("yy",li);
        return "Hello.jsp";
    }
}
